home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gscolor3.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  3.0 KB  |  93 lines

  1. /* Copyright (C) 1997, 2000 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gscolor3.c,v 1.4 2000/09/19 19:00:26 lpd Exp $ */
  20. /* "Operators" for LanguageLevel 3 color facilities */
  21. #include "gx.h"
  22. #include "gserrors.h"
  23. #include "gsmatrix.h"        /* for gscolor2.h */
  24. #include "gscolor3.h"
  25. #include "gsptype2.h"
  26. #include "gxcolor2.h"        /* for gxpcolor.h */
  27. #include "gxcspace.h"        /* for gs_cspace_init */
  28. #include "gxpcolor.h"        /* for gs_color_space_type_Pattern */
  29. #include "gzstate.h"
  30. #include "gzpath.h"
  31. #include "gxpaint.h"        /* (requires gx_path) */
  32. #include "gxshade.h"
  33.  
  34. /* setsmoothness */
  35. int
  36. gs_setsmoothness(gs_state * pgs, floatp smoothness)
  37. {
  38.     pgs->smoothness =
  39.     (smoothness < 0 ? 0 : smoothness > 1 ? 1 : smoothness);
  40.     return 0;
  41. }
  42.  
  43. /* currentsmoothness */
  44. float
  45. gs_currentsmoothness(const gs_state * pgs)
  46. {
  47.     return pgs->smoothness;
  48. }
  49.  
  50. /* shfill */
  51. int
  52. gs_shfill(gs_state * pgs, const gs_shading_t * psh)
  53. {
  54.     /*
  55.      * shfill is equivalent to filling the current clipping path (or, if
  56.      * clipping, its bounding box) with the shading, disregarding the
  57.      * Background if any.  In order to produce reasonable high-level output,
  58.      * we must actually implement this by calling gs_fill rather than
  59.      * gs_shading_fill_path.  However, filling with a shading pattern does
  60.      * paint the Background, so if necessary, we construct a copy of the
  61.      * shading with Background removed.
  62.      */
  63.     gs_pattern2_template_t pat;
  64.     gx_path cpath;
  65.     gs_matrix imat;
  66.     gs_client_color cc;
  67.     gs_color_space cs;
  68.     gx_device_color devc;
  69.     int code;
  70.  
  71.     gs_pattern2_init(&pat);
  72.     pat.Shading = psh;
  73.     gs_make_identity(&imat);
  74.     code = gs_make_pattern(&cc, (gs_pattern_template_t *)&pat, &imat, pgs,
  75.                pgs->memory);
  76.     if (code < 0)
  77.     return code;
  78.     gs_cspace_init(&cs, &gs_color_space_type_Pattern, NULL);
  79.     cs.params.pattern.has_base_space = false;
  80.     code = cs.type->remap_color(&cc, &cs, &devc, (gs_imager_state *)pgs,
  81.                 pgs->device, gs_color_select_texture);
  82.     if (code >= 0) {
  83.     gx_path_init_local(&cpath, pgs->memory);
  84.     code = gx_cpath_to_path(pgs->clip_path, &cpath);
  85.     if (code >= 0)
  86.         code = gx_fill_path(&cpath, &devc, pgs, gx_rule_winding_number,
  87.                 fixed_0, fixed_0);
  88.     gx_path_free(&cpath, "gs_shfill");
  89.     }
  90.     gs_pattern_reference(&cc, -1);
  91.     return code;
  92. }
  93.